package com.ruoyi.zsyh.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.zsyh.domain.ZsyhServiceTypeMoney;
import com.ruoyi.zsyh.service.IZsyhServiceTypeMoneyService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 维修定价标准Controller
 * 
 * @author yuexl
 * @date 2024-08-22
 */
@Controller
@RequestMapping("/zsyh/serviceTypeMoney")
public class ZsyhServiceTypeMoneyController extends BaseController
{
    private String prefix = "zsyh/serviceTypeMoney";

    @Autowired
    private IZsyhServiceTypeMoneyService zsyhServiceTypeMoneyService;

    @RequiresPermissions("zsyh:serviceTypeMoney:view")
    @GetMapping()
    public String serviceTypeMoney()
    {
        return prefix + "/serviceTypeMoney";
    }

    /**
     * 查询维修定价标准列表
     */
    @RequiresPermissions("zsyh:serviceTypeMoney:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(ZsyhServiceTypeMoney zsyhServiceTypeMoney)
    {
        startPage();
        List<ZsyhServiceTypeMoney> list = zsyhServiceTypeMoneyService.selectZsyhServiceTypeMoneyList(zsyhServiceTypeMoney);
        return getDataTable(list);
    }

    /**
     * 导出维修定价标准列表
     */
    @RequiresPermissions("zsyh:serviceTypeMoney:export")
    @Log(title = "维修定价标准", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(ZsyhServiceTypeMoney zsyhServiceTypeMoney)
    {
        List<ZsyhServiceTypeMoney> list = zsyhServiceTypeMoneyService.selectZsyhServiceTypeMoneyList(zsyhServiceTypeMoney);
        ExcelUtil<ZsyhServiceTypeMoney> util = new ExcelUtil<ZsyhServiceTypeMoney>(ZsyhServiceTypeMoney.class);
        return util.exportExcel(list, "维修定价标准数据");
    }

    /**
     * 新增维修定价标准
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存维修定价标准
     */
    @RequiresPermissions("zsyh:serviceTypeMoney:add")
    @Log(title = "维修定价标准", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(ZsyhServiceTypeMoney zsyhServiceTypeMoney)
    {
        return toAjax(zsyhServiceTypeMoneyService.insertZsyhServiceTypeMoney(zsyhServiceTypeMoney));
    }

    /**
     * 修改维修定价标准
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") String id, ModelMap mmap)
    {
        ZsyhServiceTypeMoney zsyhServiceTypeMoney = zsyhServiceTypeMoneyService.selectZsyhServiceTypeMoneyById(id);
        mmap.put("zsyhServiceTypeMoney", zsyhServiceTypeMoney);
        return prefix + "/edit";
    }

    /**
     * 修改保存维修定价标准
     */
    @RequiresPermissions("zsyh:serviceTypeMoney:edit")
    @Log(title = "维修定价标准", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(ZsyhServiceTypeMoney zsyhServiceTypeMoney)
    {
        return toAjax(zsyhServiceTypeMoneyService.updateZsyhServiceTypeMoney(zsyhServiceTypeMoney));
    }

    /**
     * 删除维修定价标准
     */
    @RequiresPermissions("zsyh:serviceTypeMoney:remove")
    @Log(title = "维修定价标准", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(zsyhServiceTypeMoneyService.deleteZsyhServiceTypeMoneyByIds(ids));
    }
}
